﻿using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;
using System.Windows;
using System.Windows.Controls;

namespace Com.CodePlex.SPPower.View {

	public class CmdParameterTemplateSelector : DataTemplateSelector {

		public DataTemplate StringTemplate { get; set; }
        public DataTemplate CheckBoxTemplate { get; set; }
        public DataTemplate ComboBoxTemplate { get; set; }
		public DataTemplate UnknownTemplate { get; set; }

		public override DataTemplate SelectTemplate(object item, DependencyObject container) {
			ViewModel.CmdParameterViewModel model = (ViewModel.CmdParameterViewModel)item;
			if(model.Type == typeof(bool)) {
                return CheckBoxTemplate;
            } else if (model.Type == typeof(string) || model.Type == typeof(int) || model.Type == typeof(Int64)) {
				return StringTemplate;
			} else if (model.Type == typeof(string[]) || model.Type == typeof(int[])) {
				return StringTemplate;
			} else if (model.Type == typeof(System.Management.Automation.SwitchParameter)) {
                return CheckBoxTemplate;
			} else if (model.Type == typeof(System.Management.Automation.ActionPreference)) {
                return ComboBoxTemplate;
			} else {
				return UnknownTemplate;
			}
		}
	}
}
